#include "StdAfx.h"
#include "libs\include\RF25xDevice.h"

using namespace RFDevice;

extern "C"
{

	RFDEVICEPROXYDLL RF25xDevice* CALLING_CONVENTION CreateRF25xDevice()
	{
		return new RF25xDevice();
	}

	RFDEVICEPROXYDLL void CALLING_CONVENTION DisposeRF25xDevice(RF25xDevice* rf)
	{
		rf->~RF25xDevice();
		rf = NULL;
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_HelloCmd_1(RF25xDevice* rf, BYTE ucAddress, LPRF25xHELLOANSWER answer)
	{
		return rf->HelloCmd(ucAddress, answer);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_HelloCmd(RF25xDevice* rf)
	{
		return rf->HelloCmd();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_GetTimeouts(RF25xDevice* rf, LPDWORD	lpdwReadIntervalTimeout,
		LPDWORD	lpdwReadTotalTimeoutMultiplier,
		LPDWORD	lpdwReadTotalTimeoutConstant,
		LPDWORD	lpdwWriteTotalTimeoutMultiplier, 
		LPDWORD	lpdwWriteTotalTimeoutConstant)
	{
		return rf->GetTimeouts(lpdwReadIntervalTimeout,
			lpdwReadTotalTimeoutMultiplier,
			lpdwReadTotalTimeoutConstant,
			lpdwWriteTotalTimeoutMultiplier, 
			lpdwWriteTotalTimeoutConstant);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_SetTimeouts(RF25xDevice* rf, DWORD		dwReadIntervalTimeout,
		DWORD		dwReadTotalTimeoutMultiplier,
		DWORD		dwReadTotalTimeoutConstant,
		DWORD		dwWriteTotalTimeoutMultiplier, 
		DWORD		dwWriteTotalTimeoutConstant)
	{
		return rf->SetTimeouts(dwReadIntervalTimeout,
			dwReadTotalTimeoutMultiplier,
			dwReadTotalTimeoutConstant,
			dwWriteTotalTimeoutMultiplier, 
			dwWriteTotalTimeoutConstant);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_GetSingleMeasure(RF25xDevice* rf, USHORT* lpusValue)
	{
		return rf->GetSingleMeasure(lpusValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_GetStreamMeasures(RF25xDevice* rf, LPRF60xSTREAMVALUE lpusStreamValues, 
		DWORD dwMeasuresCount, LPDWORD lpdwReadedMeasuresCount, LPDWORD lpdwBrokenPacketsCount)
	{
		return rf->GetStreamMeasures(lpusStreamValues, dwMeasuresCount, lpdwReadedMeasuresCount, lpdwBrokenPacketsCount);
	}
	
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_EnableSensor(RF25xDevice* rf, BOOL bEnable = TRUE)
	{
		return rf->EnableSensor(bEnable);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_SetSample(RF25xDevice* rf, BYTE ucValue)
	{
		return rf->SetSample(ucValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_SetSampleModeToTime(RF25xDevice* rf)
	{
		return rf->SetSampleModeToTime();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_SetSampleModeToClk(RF25xDevice* rf)
	{
		return rf->SetSampleModeToClk();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_SetNetworkAddress(RF25xDevice* rf, BYTE ucValue)
	{
		return rf->SetNetworkAddress(ucValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_SetBaundRate(RF25xDevice* rf, DWORD dwValue)
	{
		return rf->SetBaundRate(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_SetCoordStartPoint(RF25xDevice* rf, DWORD dwValue)
	{
		return rf->SetCoordStartPoint(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_SetSamplingPeriod(RF25xDevice* rf, DWORD dwValue)
	{
		return rf->SetSamplingPeriod(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_SetBeginAnalogRange(RF25xDevice* rf, DWORD dwValue)
	{
		return rf->SetBeginAnalogRange(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_SetEndAnalogRange(RF25xDevice* rf, DWORD dwValue)
	{
		return rf->SetEndAnalogRange(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_SetAnalogOutScaling(RF25xDevice* rf, DWORD dwValue)
	{
		return rf->SetAnalogOutScaling(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_SetLowLimitOC(RF25xDevice* rf, DWORD dwValue)
	{
		return rf->SetLowLimitOC(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_SetUpLimitOC(RF25xDevice* rf, DWORD dwValue)
	{
		return rf->SetUpLimitOC(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_SetLogicOutPolarity(RF25xDevice* rf, DWORD dwValue)
	{
		return rf->SetLogicOutPolarity(dwValue);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_SetLowLimitOutPolarityHA(RF25xDevice* rf)
	{
		return rf->SetLowLimitOutPolarityHA();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_SetLowLimitOutPolarityLA(RF25xDevice* rf)
	{
		return rf->SetLowLimitOutPolarityLA();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_SetUpLimitOutPolarityLA(RF25xDevice* rf)
	{
		return rf->SetUpLimitOutPolarityLA();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_SetUpLimitOutPolarityHA(RF25xDevice* rf)
	{
		return rf->SetUpLimitOutPolarityHA();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_GetPowerState(RF25xDevice* rf)
	{
		return rf->GetPowerState();
	}

	RFDEVICEPROXYDLL BYTE CALLING_CONVENTION RF25xDevice_GetSampleMode(RF25xDevice* rf)
	{
		return rf->GetSampleMode();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_IsSampleModeClk(RF25xDevice* rf)
	{
		return rf->IsSampleModeClk();
	}

	RFDEVICEPROXYDLL BYTE CALLING_CONVENTION RF25xDevice_GetNetworkAddress(RF25xDevice* rf)
	{
		return rf->GetNetworkAddress();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF25xDevice_GetBaundRate(RF25xDevice* rf)
	{
		return rf->GetBaundRate();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF25xDevice_GetCoordStartPoint(RF25xDevice* rf)
	{
		return rf->GetCoordStartPoint();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF25xDevice_GetSamplingPeriod(RF25xDevice* rf)
	{
		return rf->GetSamplingPeriod();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF25xDevice_GetBeginAnalogRange(RF25xDevice* rf)
	{
		return rf->GetBeginAnalogRange();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF25xDevice_GetEndAnalogRange(RF25xDevice* rf)
	{
		return rf->GetEndAnalogRange();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF25xDevice_GetAnalogOutScaling(RF25xDevice* rf)
	{
		return rf->GetAnalogOutScaling();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF25xDevice_GetLowLimitOC(RF25xDevice* rf)
	{
		return rf->GetLowLimitOC();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF25xDevice_GetUpLimitOC(RF25xDevice* rf)
	{
		return rf->GetUpLimitOC();
	}

	RFDEVICEPROXYDLL DWORD CALLING_CONVENTION RF25xDevice_GetLogicOutPolarity(RF25xDevice* rf)
	{
		return rf->GetLogicOutPolarity();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_IsLowLimitOutPolarityHA(RF25xDevice* rf)
	{
		return rf->IsLowLimitOutPolarityHA();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_IsUpLimitOutPolarityHA(RF25xDevice* rf)
	{
		return rf->IsUpLimitOutPolarityHA();
	}

	RFDEVICEPROXYDLL LPRF25XPARAMS CALLING_CONVENTION RF25xDevice_GetParams(RF25xDevice* rf)
	{
		return rf->GetParams();
	}

	//////////////////////////////////////////////////////////////////////////
	// RFComDevice
	//////////////////////////////////////////////////////////////////////////

	RFDEVICEPROXYDLL void CALLING_CONVENTION RF25xDevice_BindNetworkAddress(RF25xDevice* rf, BYTE ucAddress)
	{
		rf->BindNetworkAddress(ucAddress);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_OpenPort(RF25xDevice* rf, LPCSTR lpPort_Name, DWORD dwSpeed)
	{
		return rf->OpenPort(lpPort_Name, dwSpeed);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_ClosePort(RF25xDevice* rf)
	{
		return rf->ClosePort();
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_ReadParameter(RF25xDevice* rf, BYTE bAddress, WORD wParameter, DWORD* lpdwValue)
	{
		return rf->ReadParameter(bAddress, wParameter, lpdwValue);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_WriteParameter(RF25xDevice* rf, BYTE bAddress, WORD wParameter, DWORD dwValue)
	{
		return rf->WriteParameter(bAddress, wParameter, dwValue);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_ReadCustomParameter(RF25xDevice* rf, BYTE bAddress, BYTE bParameterAddress, BYTE bParameterSize, void* lpValue)
	{
		return rf->ReadCustomParameter(bAddress, bParameterAddress, bParameterSize, lpValue);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_WriteCustomParameter(RF25xDevice* rf, BYTE bAddress, BYTE bParameterAddress, BYTE bParameterSize, void* lpValue)
	{
		return rf->WriteCustomParameter(bAddress, bParameterAddress, bParameterSize, lpValue);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_FlushToFlash(RF25xDevice* rf, BYTE bAddress)
	{
		return rf->FlushToFlash(bAddress);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_RestoreFromFlash(RF25xDevice* rf, BYTE bAddress)
	{
		return rf->RestoreFromFlash(bAddress);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_LockResult(RF25xDevice* rf, BYTE bAddress)
	{
		return rf->LockResult(bAddress);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_Measure(RF25xDevice* rf, BYTE bAddress, USHORT* lpusValue)
	{
		return rf->Measure(bAddress, lpusValue);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_StartStream(RF25xDevice* rf)
	{
		return rf->StartStream();
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_StopStream(RF25xDevice* rf)
	{
		return rf->StopStream();
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_GetStreamMeasure(RF25xDevice* rf, USHORT* lpusValue)
	{
		return rf->GetStreamMeasure(lpusValue);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_CustomCmd(RF25xDevice* rf, char * pcInData, DWORD dwInSize, char * pcOutData, DWORD * pdwOutSize)
	{
		return rf->CustomCmd(pcInData, dwInSize, pcOutData, pdwOutSize);
	}
	RFDEVICEPROXYDLL HANDLE CALLING_CONVENTION RF25xDevice_GetPortHandle(RF25xDevice* rf)
	{
		return rf->GetPortHandle();
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_ValidateData(LPBYTE lpucData, const int nDataLength)
	{
		return RF25xDevice::ValidateData(lpucData, nDataLength);
	}

	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_EthernetOpenPort(RF25xDevice* rf)
	{
		return rf->EthernetOpenPort();
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_EthernetSetTimeout(RF25xDevice* rf, DWORD dwTimeout)
	{
		return rf->EthernetSetTimeout(dwTimeout);
	}
	RFDEVICEPROXYDLL BOOL CALLING_CONVENTION RF25xDevice_EthernetClosePort(RF25xDevice* rf)
	{
		return rf->EthernetClosePort();
	}
}